package day17.zhiyou100;

import java.io.*;

// 字节输入缓冲流
public class Demo07_BufferedInputStream {

    public static void main(String[] args) throws Exception {
        /*File file =  new File("D:\\aa\\bb\\buffer1.txt");
        FileInputStream fis = new FileInputStream(file);
        // 创建缓冲流
        BufferedInputStream bis = new BufferedInputStream(fis);
        byte[] bytes = new byte[3];
        int read = bis.read(bytes);// 返回值依然是读取到有效的字节个数
        System.out.println(new String(bytes));
        System.out.println(read);//*/
        File src = new File("C:\\Users\\Administrator\\Desktop\\InletexEMCFree汉化版.exe");
        File dest = new File("D:\\aa\\bb\\InletexEMCFree汉化版.exe");
        FileInputStream fis = new FileInputStream(src);
        FileOutputStream fos = new FileOutputStream(dest);
        // 创建缓冲流对象
        BufferedInputStream bis = new BufferedInputStream(fis);
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        // 边读边写
        long start = System.currentTimeMillis();
        int by;
        while ((by = bis.read()) != -1) {
            bos.write(by);
        }
        long end = System.currentTimeMillis();
        System.out.println((end - start)+"毫秒");// 198毫秒  14455毫秒
        // 关闭流
        bos.close();
        bis.close();
        fos.close();
        fis.close();
    }

}
